package leetcode.lcp;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int giveGem(int[] gem, int[][] operations) {
		for (int i = 0; i < operations.length; i++) {
			int[] cur = operations[i];
			int x = cur[0], y = cur[1];
			int half = gem[x] >> 1;
			gem[y] += half;
			gem[x] -= half;
		}
		int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;
		for (int i = 0; i < gem.length; i++) {
			max = Math.max(max, gem[i]);
			min = Math.min(min, gem[i]);
		}
		return max - min;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
